#!/usr/bin/env python

from SocketServer import (TCPServer as TCP,StreamRequestHandler as SRH)
from time import ctime

HOST = ''
PORT = 9999
ADDR = (HOST, PORT)

class MyRequestHandler(SRH):
    def handle(self):
        print '...connected from:', self.client_address
        recvStr = self.rfile.readline()
        print 'c:',recvStr
        self.wfile.write( '[%s] %s' %( ctime(), recvStr ) )

tcpServ = TCP(ADDR, MyRequestHandler)
print 'waiting for connection...'
tcpServ.serve_forever()
